﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DreamBox.Admin.File
{
    public partial class FileClassUpdate : BLL.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["CID"] != null)
                {
                    DAL.PSelect ps = new DAL.PSelect();
                    DataTable dt = ps.Select("dbox_FileClass", "*", "CID=" + Request.QueryString["CID"]);

                    tbox_UCName.Text = dt.Rows[0]["CName"].ToString();
                    tbox_Sort.Text = dt.Rows[0]["Sort"].ToString();
                    cbox_IsStatus.Checked = bool.Parse(dt.Rows[0]["IsStatus"].ToString());
                }
            }
        }

        protected void btn_Post_Click(object sender, EventArgs e)
        {
            if (Request.QueryString["CID"] != null)
            {
                Model.FileClass m = new Model.FileClass();
                m.CID = int.Parse(Request.QueryString["CID"]);
                m.CName = tbox_UCName.Text.Trim();
                m.Sort = int.Parse(tbox_Sort.Text.Trim());
                m.IsStatus = cbox_IsStatus.Checked;

                DAL.MAction action = new DAL.MAction();
                if (action.Update(m))
                {
                    BLL.Admin.Tips.DetailedTips(this, "操作成功","/File/FileClassList.aspx","1");
                }
            }
        }
    }
}